package lc20240424;

import java.util.*;

//华为机试HJ23 删除字符串中出现字数最少的字符
public class DeleteMinString {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        System.out.println(deleteMinString(s));
    }
    public static String deleteMinString(String s){
        Map<Character,Integer> map= new HashMap<>();
        //将字符串转变成map键值对
        for (int i = 0; i < s.length(); i++) {
            char c=s.charAt(i);
            if (map.containsKey(c)){
                map.put(c,map.get(c)+1);
            }else {
                map.put(c,1);
            }
        }
        //找到数目最少元素
        Collection<Integer> values=map.values();
        Integer min= Collections.min(values);

        //将数目最少的元素用空字符串替换
        for (Character c:map.keySet()){
            if (map.get(c).equals(min)){
                s=s.replaceAll(String.valueOf(c),"");
            }
        }
        return s;
    }
}